package vexe.web.thn.model;

import java.util.List;

import javax.jdo.PersistenceManager;
import javax.jdo.Transaction;

import vexe.web.thn.PMF;
import vexe.web.thn.jdo.PARTNERS;

public class PartnersModel {
	public PartnersModel() {

	}

	@SuppressWarnings("unchecked")
	public List<PARTNERS> getList() {
		PersistenceManager pm = PMF.get().getPersistenceManager();
		String query = "select  from " + PARTNERS.class.getName();
		List<PARTNERS> list = null;
		list = (List<PARTNERS>) pm.newQuery(query).execute();
		return list;

	}

	public void Delete(String PARTNERID) {
		PersistenceManager pm = PMF.get().getPersistenceManager();
		Transaction tx = pm.currentTransaction();
		PARTNERS partners = pm.getObjectById(PARTNERS.class, PARTNERID);

		try {
			tx.begin();
			pm.deletePersistent(partners);
			tx.commit();
		} finally {
			pm.close();
		}
	}

	public void Add(PARTNERS partners) {
		PersistenceManager pm = PMF.get().getPersistenceManager();
		Transaction tx = pm.currentTransaction();
		try {
			tx.begin();
			pm.makePersistent(partners);
			tx.commit();
		} finally {
			pm.close();
		}
	}
	public PARTNERS getPartners(String PARTNERID){
		PersistenceManager pm = PMF.get().getPersistenceManager();
		PARTNERS partners = pm.getObjectById(PARTNERS.class, PARTNERID);
		return partners;
		
	}
}
